package Test;

import Entity.ListUser;
import Entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class Handler {
    @RequestMapping("/addJSP")
    public String hello1(){
        //System.out.println("1234");
        return "index";
    }

    @RequestMapping("/addUser")
    @ResponseBody
    public String hello(User user){
        System.out.println(user);
        /*int num = id + 10;
        System.out.println(num);*/
        return "user:"+user;
    }
    @RequestMapping("/Test")
    @ResponseBody
    public String test(int id){
        return "id="+id;
    }
    @RequestMapping("/Test2")
    @ResponseBody
    public String test2(Integer id){
        return "id="+id;
    }
    @RequestMapping("/Test3")
    @ResponseBody
    public String test3(String[] name){
        StringBuffer sb = new StringBuffer();
        for (String i:name) {
            sb.append(name).append(" ");
        }
        return "name:"+sb.toString();
    }

    @RequestMapping("/getTest4")
    public String getTest4(){
        return "addUser";
    }

    @RequestMapping("/Test4")
    @ResponseBody
    public String test4(ListUser listUser){
        StringBuffer sb = new StringBuffer();
        for (User user:listUser.getUsers()) {
            sb.append(user);
        }
        return sb.toString();
    }
}
